
//beijingyanse
export function timeFormat(value, format) {
	if(!value){
		return false
	}
	const date = new Date(value * 1000)
	const y = date.getFullYear()
	const m = date.getMonth() + 1
	const d = date.getDate()
	const h = date.getHours()
	const min = date.getMinutes()
	const s = date.getSeconds()
	let result = ''
	if (format === undefined) {
		result = `${y}-${m < 10 ? '0' + m : m}-${d < 10 ? '0' + d : d} ${
        h < 10 ? '0' + h : h
      }:${min < 10 ? '0' + min : min}:${s < 10 ? '0' + s : s}`
	}
	if (format === 'yyyy-mm-dd') {
		result = `${y}-${m < 10 ? '0' + m : m}-${d < 10 ? '0' + d : d}`
	}
	if (format === 'yyyy/mm/dd') {
		result = `${y}/${m < 10 ? '0' + m : m}/${d < 10 ? '0' + d : d}`
	}
	if (format === 'yyyy.mm.dd') {
		result = `${y}+'.'+${m < 10 ? '0' + m : m}+'.'+${d < 10 ? '0' + d : d}`
	}
	if (format === 'yyyy-mm') {
		result = `${y}-${m < 10 ? '0' + m : m}`
	}
	if (format === 'mm-dd') {
		result = `${m < 10 ? '0' + m : m}:${d < 10 ? '0' + d : d}`
	}
	if (format === 'hh:mm') {
		result = `${h < 10 ? '0' + h : h}:${min < 10 ? '0' + min : min}`
	}
	if (format === 'yyyy') {
		result = `${y}`
	}
	if (format === 'ymd') {
		result = `${y}年${m}月${d}日`
	}
	if (format === 'yyyymmdd') {
		result = `${y}${m < 10 ? '0' + m : m}${d < 10 ? '0' + d : d}`
	}
	return result
}

export function happenTimeFun(num, zero) { //时间戳数据处理
console.log(num)
	let date = new Date(num);
	//时间戳为10位需*1000，时间戳为13位的话不需乘1000
	let y = date.getFullYear();
	let MM = date.getMonth() + 1;
	MM = MM < 10 ? ('0' + MM) : MM; //月补0
	let d = date.getDate();
	d = d < 10 ? ('0' + d) : d; //天补0
	let h = date.getHours();
	h = h < 10 ? ('0' + h) : h; //小时补0
	let m = date.getMinutes();
	m = m < 10 ? ('0' + m) : m; //分钟补0
	let s = date.getSeconds();
	s = s < 10 ? ('0' + s) : s; //秒补0
	if (zero == 1) {
		return y + '-' + MM + '-' + d + ' ' + '00:00:00';
	} else {
		return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
	}
}
export function filterurl(row) {
	let a =
		row.substr(0, 4) == 'http' ?
		row :
		VUE_APP_BASE_img +
		row
		console.log(a)
	return a
}
export function timeurl(row){
	return row.substring(0,10);
}

